Shell script to fix bad filenames? [closed]

Posted by Ze'ev on Server Fault See other posts from Server Fault or by Ze'ev
Published on 2012-08-20T01:51:35Z Indexed on 2012/10/05 21:39 UTC
Read the original article Hit count: 191

Filed under:
|
|
|

I'm IT at my small firm; and, despite my dire warnings, everyone puts files on the server with awful names, including leading & trailing spaces, bad characters (including \ ; / + . < > - etc!)

They do this by accessing the (FreeBSD/FreeNAS) server via AFP on Macs, so no part of the system complains.

Is there a script I can use to go through an entire directory tree and fix bad filenames?

Basically replace all spaces & bad ASCII with _ ... and if a file already exists, just slap a _2 or something on the end.

I don't suppose there's a way to get the system to enforce good filenaming conventions, is there?

© Server Fault or respective owner

Related posts about freebsd

Related posts about shell-scripting